let version = "1.0.0";
var $ = layui.$,
  dropdown = layui.dropdown;
  
layui
  .config({
    version: version, // 缓存
    //debug: true,
    base: "res/components/plugins/",
  })
  .extend({})
  .use(
    [
      "plusConfig",
      "menu",
      "plus",
      "fast",
      "element",
      "plusTools",
      "form",
      "contextMenu"
    ],
    function () {
      // 初始化layui组件库 不要命名一样的名称
      window.layer = layui.layer;
      window.table = layui.table;
      window.element = layui.element;
      window.form = layui.form;
      //快捷操作库
      window.fast = layui.fast;
      // 扩展组件库
      window.contextMenu = layui.contextMenu;
      window.plusRouter = layui.plusRouter;
      window.plusUtil = layui.plusUtil;
      window.config = layui.plusConfig;
      window.menu = layui.menu;
      window.plus = layui.plus;
      window.plusTools = layui.plusTools;

      plus.ajax("/res/datas/menus.json", function (res) {
        if (res.code === 0) {
          menu.reg(res.data, function (data) {
            data.id = data.id;
            data.parentId = data.parentId;
            data.parentIds = data.parentIds;
            data.icon = data.icon;
            data.name = data.title;
            data.url = data.path;
            data.iframe = data.component;
            data.show = !data.hide;
            data.subMenus = data.children;
            return data;
          });
          plusTools.putStore("menus", res.data);
          menu.renderMenu(res.data);
          menu.loadHome({
            url: "#/main/index",
            name: "🖥️工作台",
          });
        }
      });

      //监听浏览器变化
      window.onresize = function () {
        plus.resizeTableHeight();
        plus.resizeTable();
      };
    }
  );
